$(function() {

   //楼栋切换按钮变色
   if($('body').data('page')=='building'){
       $('#grp'+group).removeClass('btn-warning').addClass('btn-danger active').css('color','white');
       $('.groups').not($('#grp'+group)).removeClass('btn-danger active').addClass('btn-warning').css('color','black');
       $('#btn'+build).removeClass('btn-success').addClass('btn-danger active');
       $('.builds').not($('#btn'+build)).removeClass('btn-danger active').addClass('btn-success');
       $('.building').click(function(){
          var building=$(this).data('building');
          if(building == undefined){
            building='';
          }
          var group_id=$(this).data('group_id');
          var page=$(this).data('page');
          var param="?building="+building+"&group_id="+group_id;
          location.href=eval(page+"_url")+param;
       });
    }
   //验证确认操作
   $('.passcal').click(function(){
        var id=$(this).data('id');
        var status=$(this).data('status');
        $.post(passcal_url,{'id':id,'status':status},function(backdata){
            if(backdata.code==1){
                location.href="";
            }
        });
   });

   //根据验证状态进行筛选
   $('.status').click(function(){
       var status=$(this).data('status');
       var param="?building="+build+"&status="+status;
      location.href=index_url+param;
   });

    $('.status-toggle').click(function(){
       var status=$(this).data('status');
       console.log(status);
       if(status==1){
            status=2;
       }else{
         status=1;
       }
       var param="?building="+build+"&status="+status;
      location.href=index_url+param;
   });

    //完整模式和精简模式切换
    $('#s-mode').click(function(){
        var cpage=$(this).data('cpage');
        if(cpage=='simple'){
          location.href=index_url;
        }else if(cpage=='index'){
          location.href=simple_url;
        }else{
          
          location.href=simple_url;
        }
    });

    $('#simple-toggle').click(function(){
      var cpage=$(this).data('cpage');
      if(cpage=='simple'){
        location.href=simpleNew_url;
      }else if(cpage=='simpleNew'){
        location.href=simple_url;
      }else{
        
        location.href=simple_url;
      }
  });


     if(status==1){
       $('#check-toggle').text('待验证');
     }else{

       $('#check-toggle').text('已验证');
     }

     $('#check-toggle').click(function(){
       var status=$(this).data('status');
       console.log(status);
       if(status==1){
        status=2;
      }else{
        status=1;
      }
      var param="?building="+build+"&status="+status;
       // var param="?status="+status;
       location.href=simple_url+param;
     });
     
});
